#include "ndame.h"
Go to the source code of this file.
Functions | |
void | filename (struct data *d1) |
filename |
Definition in file filename.c.
|
filename In this file you can choose the HDD and then you can enter a new filename with 13 signs.This programme donīt accept invalid signes. When you press enter the function only accept a filename >0 signes else default name "..\ndame.txt" will not be changed.
Definition at line 23 of file filename.c. 00024 { 00025 char cbackslash[4]=":\\"; 00026 char cdrive[2]; 00027 char ccfilename[100]="ndame.txt"; 00028 char ctemp[100]; 00029 char cinput; 00030 int iascii; 00031 int icount=0; 00032 00033 gotoxy(2,5); 00034 printf("Select drive (A),(B),(C),(...),(Z)"); 00035 00036 do //select HDD 00037 { 00038 cdrive[0]=getch(); 00039 if(islower(cdrive[0])) 00040 { 00041 cdrive[0]=toupper(cdrive[0]); //programme makes no difference 00042 } //between small or big letters 00043 iascii=cdrive[0]; 00044 }while(iascii<65||iascii>90); 00045 00046 00047 gotoxy(2,7); 00048 printf("(%s) entered",cdrive); 00049 gotoxy(2,9); 00050 printf("Please enter filename [*.*]"); 00051 gotoxy(2,11); 00052 printf("%s:\\",cdrive); 00053 00054 gotoxy(5,11); 00055 00056 do //filename input 00057 { //not all signs are valid 00058 cinput=getch(); 00059 if((cinput>=48&&cinput<=57)||(cinput>=65&&cinput<=90)||(cinput>=97&&cinput<=122)||cinput==46||cinput==13||cinput==8||cinput==95||cinput==92) 00060 { 00061 if((strlen(ccfilename)<17)&&(cinput!=8)&&(cinput!=13)) 00062 { 00063 putch(cinput); 00064 ccfilename[icount]=cinput; 00065 ccfilename[icount+1]=0; 00066 icount++; 00067 } 00068 00069 if(cinput==8) //8=backspace 00070 { 00071 icount=0; 00072 sprintf(ccfilename,"%s","ndame.txt"); //default name 00073 gotoxy(5,11); 00074 printf(" "); 00075 gotoxy(5,11); 00076 } 00077 } 00078 00079 }while(cinput!=13); //pressing enter the filename is accepted 00080 00081 strcpy(ctemp,cdrive); //all parts become one filename 00082 strcat(ctemp,cbackslash); 00083 strcat(ctemp,ccfilename); 00084 strcpy(d1->cfilename,ctemp); //filename copied in struct 00085 00086 //printf("\n%s",d1->cfilename); 00087 //getch(); 00088 00089 clrbox(0); 00090 state(d1,4); 00091 }
|